<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>login</title>
</head>
<h2>用户登录</h2>
<body>
	<form action="AccountServlet?method=loginConfig" method="post">
		账号：<input type="text" id="username" maxlength="20" name="username" value="${cookie.username.value }" >
		<span id="username_check"></span><br /><br />
		密码：<input type="password" id="password" maxlength=20 name="password" value="${cookie.password.value }" >
		<span id="password_check"></span><br /> 
		验证码：<input type="text" id="code" name="code" size="8"/>
		<img alt="验证码找不到" src="kaptcha.jpg" width="100" height="50" id="kaptcha"/><br />
		${codeFail }
		<input type="checkbox" name="save" value="yes" ${cookie.save.value eq 'yes' ? "checked='checked'" : ''}>保存我的账号<br />
		<input type="submit" id="submit" value="提交"> 
		<input type="reset" value="重置">
	</form>
	<a href="create.jsp"><input type="button" value="注册新的账号"></a>
	
	<script src="js/jquery-3.4.1.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			var result = true;
			$("#submit").click(function(){
				if($("#username").val()==""){
					$("#username_check").html("账号不可为空");
					result = false;
				}else{
					$("#username_check").html("");
				}
				if($("#password").val()==""){
					$("#password_check").html("密码不可为空");
					result = false;
				}else{
					$("span#password_check").html("");
				}
				return result;
			})
			
			$("#kaptcha").click(function(){
				$("img").attr("src","kaptcha.jpg?"+Math.floor(Math.random()*100));
			});
		})
	</script>
</body>
</html>